﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.Text;
using DTOSingTowerMall;
using FacadeSingTowerMall;
using ContractSingTowerMall;

namespace ServiceHostSingTowerMall
{
    // NOTE: You can use the "Rename" command on the "Refactor" menu to change the class name "EventService" in code, svc and config file together.
           [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)]
    public class EventService : IEventService
    {
        EventFacade ef = new EventFacade();


        public EventDetailList GetEventDetails(DateTime fromDate, DateTime toDate)
        {
            EventDetailList edl = new EventDetailList();
            IQueryable<IEventHallBooking> allBookings = ef.getEventsBetween(fromDate, toDate);
            EventAdapter ea = new EventAdapter();
            foreach(IEventHallBooking booking in allBookings)
            {
                EventDetail ed = ea.GetEventDetail(booking);
                edl.Add(ed);
            }
            return edl;
        }

        public EventDetailList GoodMorning(DateTime fromDate, DateTime toDate)
        {
            EventDetailList edl = new EventDetailList();
            IQueryable<IEventHallBooking> eh = ef.getEventsBetween(fromDate,toDate);
            EventAdapter ea = new EventAdapter();
            foreach (IEventHallBooking e in eh)
            {
                EventDetail ed = ea.GetEventDetail(e);
                edl.Add(ed);
            }
            return edl;
        }
    }
}
